Skip to content

fix: document request body plaintext disk spooling and mitigation steps#381

Open
eilandert wants to merge 1 commit into
owasp-modsecurity:masterfrom
eilandert:fix/request-body-tempfile-security
Open

fix: document request body plaintext disk spooling and mitigation steps#381
eilandert wants to merge 1 commit into
owasp-modsecurity:masterfrom
eilandert:fix/request-body-tempfile-security

Conversation

@eilandert
Copy link
Copy Markdown

request_body_in_persistent_file unconditionally spools all client request bodies to disk as plaintext temporary files. This bypasses client_body_buffer_size, meaning even small bodies end up on disk.

In environments handling sensitive POST data (authentication, payment, health records), this creates plaintext files readable by any process with access to client_body_temp_path, which defaults to a world- accessible directory under the nginx prefix.

Add a security comment at the point of the flag assignment documenting:

  • The nature of the exposure (plaintext temp files regardless of buffer)
  • The recommended mitigation: client_body_temp_path to a tmpfs mount such as /dev/shm/nginx_body with 0700 permissions
  • The recommended size limits to constrain disk usage

A proper fix would only spool to disk when body size exceeds client_body_buffer_size and use the configured temp path with restrictive permissions. This comment serves as a clear callout for operators reviewing the source and for future refactoring.

request_body_in_persistent_file unconditionally spools all client
request bodies to disk as plaintext temporary files. This bypasses
client_body_buffer_size, meaning even small bodies end up on disk.

In environments handling sensitive POST data (authentication, payment,
health records), this creates plaintext files readable by any process
with access to client_body_temp_path, which defaults to a world-
accessible directory under the nginx prefix.

Add a security comment at the point of the flag assignment documenting:
- The nature of the exposure (plaintext temp files regardless of buffer)
- The recommended mitigation: client_body_temp_path to a tmpfs mount
  such as /dev/shm/nginx_body with 0700 permissions
- The recommended size limits to constrain disk usage

A proper fix would only spool to disk when body size exceeds
client_body_buffer_size and use the configured temp path with
restrictive permissions. This comment serves as a clear callout for
operators reviewing the source and for future refactoring.

Severity: High in multi-tenant environments, Medium in single-tenant
Reported-by: Security audit 2026-05-13
@sonarqubecloud
Copy link
Copy Markdown

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds an in-source security comment above the r->request_body_in_persistent_file = 1; assignment in the ModSecurity-nginx access handler. The comment documents that ModSecurity-nginx forces request bodies to be spooled to disk as plaintext, and suggests operator mitigations (tmpfs-backed client_body_temp_path, restrictive permissions, and size limits).

Changes:

  • Adds a multi-line SECURITY NOTE comment in ngx_http_modsecurity_access_handler describing the disk-spooling behavior and mitigations.
  • No functional/code changes.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants